Skip to content

fix: allow concurrent tool execution within the same MCP extension#7202

Merged
angiejones merged 1 commit intoblock:mainfrom
rabi:7201
Feb 13, 2026
Merged

fix: allow concurrent tool execution within the same MCP extension#7202
angiejones merged 1 commit intoblock:mainfrom
rabi:7201

Conversation

@rabi
Copy link
Contributor

@rabi rabi commented Feb 13, 2026

Summary

Refactor GooseClient session tracking from a single-slot session_id to a refcounted ActiveSession struct behind one Mutex, so concurrent requests safely share the session_id and it is cleared only when the last request completes.

Type of Change

  • [] Feature
  • Bug fix
  • Refactor / Code quality
  • Performance improvement
  • Documentation
  • Tests
  • Security fix
  • Build / Release
  • Other (specify below)

AI Assistance

  • This PR was created or reviewed with AI assistance

Testing

Tested Locally

Related Issues

Closes: #7201

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical concurrency bug where multiple tool calls to the same MCP extension were being serialized instead of executing in parallel. The fix refactors session tracking from a single-slot design to a refcounted ActiveSession struct and removes the outer Arc<Mutex<>> wrapper around McpClientTrait that was preventing concurrent execution.

Changes:

  • Introduced ActiveSession struct with refcounting to track concurrent requests sharing the same session
  • Changed McpClientBox from Arc<Mutex<Box<dyn McpClientTrait>>> to Arc<dyn McpClientTrait>, removing the serialization bottleneck
  • Updated all call sites to remove unnecessary lock().await calls that are no longer needed

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
crates/goose/src/agents/mcp_client.rs Introduced ActiveSession with acquire_session/release_session refcounting; updated session tracking logic
crates/goose/src/agents/extension_manager.rs Removed Arc<Mutex<>> wrapper from McpClientBox type; removed all lock().await calls on clients; updated test mocks
crates/goose-cli/src/scenario_tests/scenario_runner.rs Updated test mock client instantiation to match new McpClientBox type

Copy link
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Remove the outer Mutex from McpClientBox so concurrent tool calls to
the same extension can overlap.  GooseClient now stores a set-once
session_id (invariant per McpClient) for server-initiated callbacks,
guarded by a debug_assert.

Change-Id: Ie94c41d3510b85e7332b08132f8360869ac2bf9d
Signed-off-by: rabi <ramishra@redhat.com>
@angiejones
Copy link
Collaborator

thank you so much @rabi! beautiful fix

@angiejones angiejones added this pull request to the merge queue Feb 13, 2026
Merged via the queue into block:main with commit ad3bea3 Feb 13, 2026
19 checks passed
jh-block added a commit that referenced this pull request Feb 13, 2026
* origin/main:
  fix: allow concurrent tool execution within the same MCP extension (#7202)
  fix: handle missing arguments in MCP tool calls to prevent GUI crash (#7143)
  Filter Apps page to only show standalone Goose Apps (#6811)
  opt: use static for Regex (#7205)
katzdave added a commit that referenced this pull request Feb 13, 2026
…ntext

* 'main' of github.com:block/goose:
  feat: add onFallbackRequest handler to McpAppRenderer (#7208)
  feat: add streaming support for Claude Code CLI provider (#6833)
  fix: The detected filetype is PLAIN_TEXT, but the provided filetype was HTML (#6885)
  Add prompts (#7212)
  Add testing instructions for speech to text (#7185)
  Diagnostic files copying (#7209)
  fix: allow concurrent tool execution within the same MCP extension (#7202)
  fix: handle missing arguments in MCP tool calls to prevent GUI crash (#7143)
  Filter Apps page to only show standalone Goose Apps (#6811)
  opt: use static for Regex (#7205)
  nit: show dir in title, and less... jank (#7138)
  feat(gemini-cli): use stream-json output and re-use session (#7118)
  chore(deps): bump qs from 6.14.1 to 6.14.2 in /documentation (#7191)
  Switch jsonwebtoken to use aws-lc-rs (already used by rustls) (#7189)
  chore(deps): bump qs from 6.14.1 to 6.14.2 in /evals/open-model-gym/mcp-harness (#7184)
  Add SLSA build provenance attestations to release workflows (#7097)
  fix save and run recipe not working (#7186)
  Upgraded npm packages for latest security updates (#7183)
  docs: reasoning effort levels for Codex provider (#6798)
michaelneale added a commit that referenced this pull request Feb 16, 2026
* origin/main: (42 commits)
  fix: use dynamic port for Tetrate auth callback server (#7228)
  docs: removing LLM Usage admonitions (#7227)
  feat(otel): respect standard OTel env vars for exporter selection (#7144)
  fix: fork session (#7219)
  Bump version numbers for 1.24.0 release (#7214)
  Move platform extensions into their own folder (#7210)
  fix: ignore deprecated skills extension (#7139)
  Add a goosed over HTTP integration test, and test the developer tool PATH (#7178)
  feat: add onFallbackRequest handler to McpAppRenderer (#7208)
  feat: add streaming support for Claude Code CLI provider (#6833)
  fix: The detected filetype is PLAIN_TEXT, but the provided filetype was HTML (#6885)
  Add prompts (#7212)
  Add testing instructions for speech to text (#7185)
  Diagnostic files copying (#7209)
  fix: allow concurrent tool execution within the same MCP extension (#7202)
  fix: handle missing arguments in MCP tool calls to prevent GUI crash (#7143)
  Filter Apps page to only show standalone Goose Apps (#6811)
  opt: use static for Regex (#7205)
  nit: show dir in title, and less... jank (#7138)
  feat(gemini-cli): use stream-json output and re-use session (#7118)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parallel Subagent Execution is Serialized

3 participants

Comments